package com.kifas.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "tb_penjualan")
public class PenjualanEntity implements Serializable {

	private static final long serialVersionUID = 4742438135971916156L;

	@Id
	@GeneratedValue
	@Column(name = "id_penjualan")
	private Long idPenjualan;

	private String noPenjualan;

	@ManyToOne
	@JoinColumn(name = "id_customer", nullable = false)
	private CustomerEntity customer;

	@ManyToOne
	@JoinColumn(name = "id_sales", nullable = false)
	private SalesEntity sales;

	@OneToMany(mappedBy = "penjualan", targetEntity = PenjualanDetailEntity.class, fetch = FetchType.LAZY)
	private Set<PenjualanDetailEntity> penjualanDetails;

	@Temporal(TemporalType.TIMESTAMP)
	private Date tanggal;

	private String isPajak;

	@Column(name = "alamat_kirim")
	private String alamatKirim;

	private BigDecimal total;

	private BigDecimal biayaLain;

	@Column(name = "tanggal_kirim")
	@Temporal(TemporalType.TIMESTAMP)
	private Date tanggalKirim;

	@Column(name = "tanggal_jatuh_tempo")
	@Temporal(TemporalType.TIMESTAMP)
	private Date tanggalJatuhTempo;

	private String keterangan;

	@Column(name = "nomor_po")
	private String nomorPo;

	@Column(name = "is_kirim", nullable = false)
	private boolean kirim;

	@Column(name = "is_closed", nullable = false)
	private boolean closed = false;

	@Column(name = "is_canceled", nullable = false)
	private boolean canceled;
	
	@Column(name= "created_by")
	private String createdBy;
	
	@Column(name= "created_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	public PenjualanEntity() {
	}

	public PenjualanEntity(Long idPenjualan, String noPenjualan,
			CustomerEntity customer, SalesEntity sales, Date tanggal,
			String isPajak, String alamatKirim, BigDecimal total,
			Date tanggalKirim, Date tanggalJatuhTempo, String keterangan,
			BigDecimal biayaLain, String nomorPo, String createdBy, Date createdDate) {
		this.idPenjualan = idPenjualan;
		this.noPenjualan = noPenjualan;
		this.customer = customer;
		this.sales = sales;
		this.tanggal = tanggal;
		this.isPajak = isPajak;
		this.alamatKirim = alamatKirim;
		this.total = total;
		this.tanggalKirim = tanggalKirim;
		this.tanggalJatuhTempo = tanggalJatuhTempo;
		this.keterangan = keterangan;
		this.biayaLain = biayaLain;
		this.nomorPo = nomorPo;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}

	public PenjualanEntity(Long idPenjualan, String noPenjualan,
			CustomerEntity customer, SalesEntity sales, Date tanggal,
			String isPajak, String alamatKirim, BigDecimal total,
			Date tanggalKirim, Date tanggalJatuhTempo, String keterangan,
			Set<PenjualanDetailEntity> penjualanDetails, BigDecimal biayaLain, String nomorPo, String createdBy, Date createdDate) {
		this.idPenjualan = idPenjualan;
		this.noPenjualan = noPenjualan;
		this.customer = customer;
		this.sales = sales;
		this.tanggal = tanggal;
		this.isPajak = isPajak;
		this.alamatKirim = alamatKirim;
		this.total = total;
		this.tanggalKirim = tanggalKirim;
		this.tanggalJatuhTempo = tanggalJatuhTempo;
		this.keterangan = keterangan;
		this.penjualanDetails = penjualanDetails;
		this.biayaLain = biayaLain;
		this.nomorPo = nomorPo;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}

	public BigDecimal getBiayaLain() {
		return biayaLain;
	}

	public void setBiayaLain(BigDecimal biayaLain) {
		this.biayaLain = biayaLain;
	}

	public Long getIdPenjualan() {
		return idPenjualan;
	}

	public void setIdPenjualan(Long idPenjualan) {
		this.idPenjualan = idPenjualan;
	}

	public String getNoPenjualan() {
		return noPenjualan;
	}

	public void setNoPenjualan(String noPenjualan) {
		this.noPenjualan = noPenjualan;
	}

	public CustomerEntity getCustomer() {
		return customer;
	}

	public void setCustomer(CustomerEntity customer) {
		this.customer = customer;
	}

	public SalesEntity getSales() {
		return sales;
	}

	public void setSales(SalesEntity sales) {
		this.sales = sales;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public String getIsPajak() {
		return isPajak;
	}

	public void setIsPajak(String isPajak) {
		this.isPajak = isPajak;
	}

	public String getAlamatKirim() {
		return alamatKirim;
	}

	public void setAlamatKirim(String alamatKirim) {
		this.alamatKirim = alamatKirim;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public Set<PenjualanDetailEntity> getPenjualanDetails() {
		return penjualanDetails;
	}

	public void setPenjualanDetails(Set<PenjualanDetailEntity> penjualanDetails) {
		this.penjualanDetails = penjualanDetails;
	}

	public Date getTanggalKirim() {
		return tanggalKirim;
	}

	public void setTanggalKirim(Date tanggalKirim) {
		this.tanggalKirim = tanggalKirim;
	}

	public Date getTanggalJatuhTempo() {
		return tanggalJatuhTempo;
	}

	public void setTanggalJatuhTempo(Date tanggalJatuhTempo) {
		this.tanggalJatuhTempo = tanggalJatuhTempo;
	}

	public String getKeterangan() {
		return keterangan;
	}

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	public boolean isKirim() {
		return kirim;
	}

	public void setKirim(boolean kirim) {
		this.kirim = kirim;
	}

	public boolean isCanceled() {
		return canceled;
	}

	public void setCanceled(boolean canceled) {
		this.canceled = canceled;
	}

	public boolean isClosed() {
		return closed;
	}

	public void setClosed(boolean closed) {
		this.closed = closed;
	}

	public String getNomorPo() {
		return nomorPo;
	}

	public void setNomorPo(String nomorPo) {
		this.nomorPo = nomorPo;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

}
